class UserAdminController < ApplicationController
  
#  before_filter :authorize_admin
  layout "common_layout"
def index
  redirect_to :action => :admin_login
end

 def show_paper
    @paper = Paper.find(params[:id])
  end
 
  def list_paper
    @paper_pages, @papers = paginate :papers,  :order => 'title DESC', :per_page => 10
  end
 
 def delete_paper
   Paper.find(params[:id]).destroy
   redirect_to :action=>'list_paper'
 end
 
 def list_user
    @user_pages,@users= paginate :users, :conditions => ['user_type != ?', "administrator"], :order => 'user_type,account', :per_page=>10
 end
 
 def show_user
  @user=User.find(params[:id])
 end
 
 def delete_user
   User.find(params[:id]).destroy
   redirect_to :action=>'list_user'
 end
 
 def list_teacher
   @teacher_pages,@teachers= paginate :users, :conditions => ['user_type = ?', "teacher"], :order => 'account DESC', :per_page=>10
 end
 
 def show_teacher
  @teacher=User.find(params[:id])
 end
 
 def delete_teacher
   User.find(params[:id]).destroy
   redirect_to :action=>'list_teacher'
 end
 
# def add_teacher
#   @teacher = Teacher.new(params[:teacher])
#   if request.post? and @teacher.save!
#    flash[:notice] = "Teacher Add Sucessfully!"
#
#    redirect_to(:controller =>"user_admin", :action => "list_teacher")
#   end
# end
 
  def list_student
     @student_pages, @students = paginate :users, :conditions => ['user_type = ?', "student"], :order => 'account DESC', :per_page => 10
  end
  
  def delete_student
    User.find(params[:id]).destroy
    redirect_to :action => 'list_student'
  end
  
  def show_student
    @student = User.find(params[:id])
  end
  
end
